Skip to content

Resource Managers: durable metering for the CRE and other products#2158

Open
patrickhuie19 wants to merge 9 commits into
mainfrom
feat/shared-2707
Open

Resource Managers: durable metering for the CRE and other products#2158
patrickhuie19 wants to merge 9 commits into
mainfrom
feat/shared-2707

Conversation

@patrickhuie19

@patrickhuie19 patrickhuie19 commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

Resource Managers record and measure utilization of long lived resources that drawdown from unified account balances. i.e. trigger subscriptions drawing down from a CRE account balance.

Requires

https://github.com/smartcontractkit/chainlink-protos/pull/400/commits + smartcontractkit/chainlink-protos#419 (merged)

Supports

smartcontractkit/chainlink#22845

@github-actions

github-actions Bot commented Jun 15, 2026

Copy link
Copy Markdown
Contributor

✅ API Diff Results - github.com/smartcontractkit/chainlink-common

✅ Compatible Changes (8)

package github (1)
  • com/smartcontractkit/chainlink-common/pkg/resourcemanager — ➕ Added
pkg/loop.EnvConfig (7)
  • MeterEnvironment — ➕ Added

  • MeterNodeID — ➕ Added

  • MeterProduct — ➕ Added

  • MeterRecordsEnabled — ➕ Added

  • MeterSnapshotsEnabled — ➕ Added

  • MeterTenant — ➕ Added

  • MeterZone — ➕ Added


📄 View full apidiff report

Comment thread pkg/loop/config.go
envMeteringEnvironment = "CL_METERING_ENVIRONMENT"
envMeteringZone = "CL_METERING_ZONE"
envMeteringNodeID = "CL_METERING_NODE_ID"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to reader, DonID isn't here b/c a node can belong to many DONs; it is the responsibility of the loop to properly receive its DonID from Initialise in the standard cap interface (or for non-CRE use cases, elsewhere)


"github.com/smartcontractkit/chainlink-common/pkg/chipingress"
"github.com/smartcontractkit/chainlink-common/pkg/logger"
"github.com/smartcontractkit/chainlink-common/pkg/services"

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note to reader: changes made here instead of pkg/beholder as we are trying to leave beholder as is without accruing much more complexity, and durableemitter pkg is completely owned by foundations, so is a cleaner division of responsibility

cc @pkcll

@patrickhuie19 patrickhuie19 marked this pull request as ready for review July 1, 2026 21:18
@patrickhuie19 patrickhuie19 requested a review from a team as a code owner July 1, 2026 21:18
Comment thread pkg/loop/config.go Outdated
Comment thread pkg/resourcemanager/utilization.go Outdated

// NewUtilizationString builds a Utilization from a pre-formatted numeric string
// value.
func NewUtilizationString(value string, fields UtilizationFields) *meteringpb.Utilization {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this one deserve the plain constructor name, since it is accepting the raw string?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i.e. you are saying it should be called NewUtilization?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah with NewUtilizationInt or similar for the other one

// (loop.EnvConfig), not the standard-capabilities boundary, so any LOOP plugin
// can populate the coarse metering rollup dimensions. Any field may be empty if
// the host did not provide it.
type DeploymentIdentity struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where does this get used? Are the env vars meant to plug into this struct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, the env vars plug into, passed over to the loop via env. They should then be set on the ResourceManagers config so that they can be sourced into the emission of each event.

Comment thread pkg/resourcemanager/utilization.go Outdated
}

// DonIdentifier captures DON-specific identity dimensions as one unit.
type DonIdentifier struct {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference between Identifier, Identity, and ID?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants